PKG=github.com/apulis/bmod/file-server
IMAGE?=apulistech/file-server
GIT_COMMIT?=$(shell git rev-parse --short HEAD)
GIT_BRANCH ?= $(shell git rev-parse --abbrev-ref HEAD)
BUILD_DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS?="-X ${PKG}/cmd.gitCommit=${GIT_COMMIT} -X ${PKG}/cmd.buildDate=${BUILD_DATE}"
GO111MODULE=on
GOPROXY=https://goproxy.io
GOPATH=$(shell go env GOPATH)

.EXPORT_ALL_VARIABLES:

.PHONY: build
build:
	mkdir -p bin
	GOOS=linux go build -ldflags ${LDFLAGS} -buildmode=pie -o bin/file-server main.go

.PHONY: verify
verify:
	./hack/verify-all

.PHONY: test
test:
	go test -v -race ./pkg/...

.PHONY: image
image:
	docker build -t $(IMAGE):${GIT_BRANCH}-${GIT_COMMIT} -f Dockerfile .
